﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace iHub
{
    public partial class birmonth : Form
    {
        private int m2;
        private String m;
        public birmonth()
        {
            InitializeComponent();
            this.FormClosing += new FormClosingEventHandler(Date_Closing);
        }

        private void Date_Closing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing)
            {
                main.form.Enabled = true;
            }
        }

        private void selectdate_Click(object sender, EventArgs e)
        {
            int y;

            if (monthandyear.Checked)
            {
                if (!year.Text.Equals("") && month.SelectedIndex != -1)
                {
                    m = month.SelectedItem.ToString();
                    y = Convert.ToInt32(year.Text);
                    if (m == "January")
                    {
                        m2 = 1;
                    }
                    else if (m == "February")
                    {
                        m2 = 2;
                    }
                    else if (m == "March")
                    {
                        m2 = 3;
                    }
                    else if (m == "April")
                    {
                        m2 = 4;
                    }
                    else if (m == "May")
                    {
                        m2 = 5;
                    }
                    else if (m == "June")
                    {
                        m2 = 6;
                    }
                    else if (m == "July")
                    {
                        m2 = 7;
                    }
                    else if (m == "August")
                    {
                        m2 = 8;
                    }
                    else if (m == "September")
                    {
                        m2 = 9;
                    }
                    else if (m == "October")
                    {
                        m2 = 10;
                    }
                    else if (m == "November")
                    {
                        m2 = 11;
                    }
                    else if (m == "December")
                    {
                        m2 = 12;
                    }

                    main.form.Enabled = true;
                    main.form.getBIR(m2, y,true);
                    this.Dispose();
                }
                else
                {
                    MessageBox.Show("Form is incomplete. Please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (yearonly.Checked)
            {
                if (!year.Text.Equals(""))
                {
                    y = Convert.ToInt32(year.Text);

                    main.form.Enabled = true;
                    main.form.getBIR(y, false);
                    this.Dispose();
                }
                else
                {
                    MessageBox.Show("Form is incomplete. Please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

        private void monthandyear_CheckedChanged(object sender, EventArgs e)
        {
            if (monthandyear.Checked)
            {
                month.Enabled = true;
            }
            else
            {
                month.Enabled = false;
            }
        }

        private void yearonly_CheckedChanged(object sender, EventArgs e)
        {
            if (yearonly.Checked)
            {
                month.Enabled = false;
            }
            else
            {
                month.Enabled = true;
            }
        }
    }
}
